chai = require 'chai'
chai.should()
sinon = require 'sinon'
{Token} = require "../src/token"

{Refresh} = require "../src/refresh"
{MemoryRepository} = require "../src/memoryRepository"

describe 'When I create an Access Token', ->
  it 'should store a valid token', (done)->
    tokenRepo = new MemoryRepository()
    refresh = new Refresh(null, tokenRepo, null)
    expireDate = new Date()
    expireDate.setDate( expireDate.getDate() + 1)
    refresh.createAndStoreAccessToken 'userId', expireDate.toISOString(), (err, token)->
      tokenRepo.get token.Id, (err, document)->
        document.should.not.be.null
        document.should.equal token
        done()
